﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using ElectronicCommerce.Framework.Payment.Contract.DataContract.Common;

namespace ElectronicCommerce.Framework.Payment.Contract.DataContract
{
    /// <summary>
    /// 支付请求基类
    /// </summary>
    [Serializable]
    [DataContract]
    public abstract class PaymentRequest
    {
        public PaymentRequest()
            : this("", "")
        {
        }

        public PaymentRequest(string paymentName)
            : this(paymentName, "")
        {
        }

        public PaymentRequest(string paymentName, string gatewayAddress)
        {
            GetwayAndSellerInfoIsFromConfig = true;
            EnvType = GatewayEnvType.Product;
            Seller = new Seller();
            Gateway = new Gateway(paymentName, gatewayAddress);
            ContentEncoding = "gb2312";
            RequestDate = DateTime.Now;
        }

        /// <summary>
        /// 网关信息是否从配置文件获取
        /// 网关信息的获取有两种方式：
        /// 1）从配置文件读取
        /// 2）手工赋值
        /// </summary>
        [DataMember]
        public bool GetwayAndSellerInfoIsFromConfig { get; set; }

        /// <summary>
        /// 
        /// </summary>
        [DataMember]
        public GatewayEnvType EnvType { get; set; }

        /// <summary>
        /// 卖家
        /// </summary>
        [DataMember]
        public Seller Seller { get; set; }

        /// <summary>
        /// 用什么类型网关支付
        /// </summary>
        [DataMember]
        public Gateway Gateway { get; set; }

        /// <summary>
        /// 对请求内容的编码
        /// 不同的网关支付不同的编码，以同样的编码请求响应才能验证服务器返回信息的正确
        /// </summary>
        [DataMember]
        public string ContentEncoding { get; set; }

        /// <summary>
        /// 发送到支付网关的数据
        /// </summary>
        [DataMember]
        public string RequestText { get; set; }

        /// <summary>
        /// 请求日期
        /// </summary>
        [DataMember]
        public DateTime RequestDate { get; set; }
    }
}
